<!--
 * @Author: your name
 * @Date: 2021-04-17 10:33:36
 * @LastEditTime: 2021-04-20 18:56:16
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \智慧医疗项目\app\src\views\pages\audit\audit.vue
-->
<template>
  <div class="audit">
      <el-breadcrumb>
        <el-breadcrumb-item>审核管理</el-breadcrumb-item>
      </el-breadcrumb>
      <el-row>
        <el-col class="col1" :span="7">
          <span v-for="(item,index) in navList" :key="index" @click="handleTab(item.type)" :class="item.type===type?'active':''">{{item.name}}</span>
        </el-col>
        <el-col :span="17" class="col2">
          <el-row :gutter="10">
            <el-col :span="8">
              医师职称:
              <el-select v-model="value" placeholder="普通医师">
                <el-option
                  v-for="item in options"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </el-col>
            <el-col :span="8">
              隶属医院:
              <el-input placeholder='请输入医院名称'></el-input>
            </el-col>
            <el-col :span="8">
              从医年限:
              <el-input>
                <el-button slot="append" type="primary" size='mini'>搜索</el-button>
              </el-input>
            </el-col>
          </el-row>
        </el-col>
      </el-row>
      <el-table :data='audit1' border v-if="type===1">
        <el-table-column type='index' label="序号" width="50px"></el-table-column>
        <el-table-column label="医师姓名" prop="name"></el-table-column>
        <el-table-column label="隶属医院" prop="subjection"></el-table-column>
        <el-table-column label="医师职称" prop="technical"></el-table-column>
        <el-table-column label="年限" prop="agelimit"></el-table-column>
        <el-table-column label="医师资格证书" prop="qualification"></el-table-column>
        <el-table-column label="医师执业证书" prop="practice"></el-table-column>
        <el-table-column label="身份证" prop="idcard"></el-table-column>
        <el-table-column label="操作">
          <template slot-scope="scope">
            <el-button type="text" size="small" @click="handleAudit(scope.row)">审核</el-button>
          </template>
        </el-table-column>
      </el-table>
      <el-table :data='audit2' border v-else-if="type===2">
        <el-table-column type='index' label="序号" width="50px"></el-table-column>
        <el-table-column label="医师姓名" prop="name"></el-table-column>
        <el-table-column label="隶属医院" prop="subjection"></el-table-column>
        <el-table-column label="医师职称" prop="technical"></el-table-column>
        <el-table-column label="年限" prop="agelimit"></el-table-column>
        <el-table-column label="医师资格证书" prop="qualification"></el-table-column>
        <el-table-column label="医师执业证书" prop="practice"></el-table-column>
        <el-table-column label="身份证" prop="idcard"></el-table-column>
        <el-table-column label="操作">
          <template>
            <el-button type="text" size="small">查看</el-button>
          </template>
        </el-table-column>
      </el-table>
      <el-table :data='audit3' border v-else>
        <el-table-column type='index' label="序号" width="50px"></el-table-column>
        <el-table-column label="医师姓名" prop="name"></el-table-column>
        <el-table-column label="隶属医院" prop="subjection"></el-table-column>
        <el-table-column label="医师职称" prop="technical"></el-table-column>
        <el-table-column label="年限" prop="agelimit"></el-table-column>
        <el-table-column label="医师资格证书" prop="qualification"></el-table-column>
        <el-table-column label="医师执业证书" prop="practice"></el-table-column>
        <el-table-column label="身份证" prop="idcard"></el-table-column>
        <el-table-column label="操作">
          <template>
            <el-button type="text" size="small">查看</el-button>
          </template>
        </el-table-column>
      </el-table>
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page.sync="pageIndex"
        :page-size="pageSize"
        layout="prev, pager, next, jumper"
        :total="total">
    </el-pagination>
    <el-dialog
      :modal='false'
      title="提示"
      :visible.sync="dialogVisible"
      width="80%"
      :before-close="handleClose">
      <span>这是一段信息</span>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="dialogVisible = false">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import axios from 'axios'
export default {
  created(){
    this.getAuditList()
  },
  data(){
    return {
      audit1:[],
      audit2:[],
      audit3:[],
      navList:[
        {
          name:'待审核',
          type:1
        },
        {
          name:'通过',
          type:2
        },
        {
          name:'未通过',
          type:3
        }
      ],
      type:1,
      options: [{
          value: '选项1',
          label: '普通医师'
        }, {
          value: '选项2',
          label: '主治医师'
        }],
      value: '',
      pageIndex: 1,
      pageSize: 20,
      total:0,
      dialogVisible:false
    }
  },
  methods:{
    async getAuditList(){
      const {data:res}=await axios.post('/api/audit',{
        pageIndex:this.pageIndex,
        pageSize:this.pageSize
      });
      this.total=res.total
      console.log(res,'sssssssssss');
      //console.log(this.total)
      //console.log(res.audit.filter(item=>item.type===1),'audit')
      this.audit1=res.data.filter(item=>item.type===1);
      this.audit2=res.data.filter(item=>item.type===2);
      this.audit3=res.data.filter(item=>item.type===3);
    },
    handleTab(val){
      this.type=val
    },
    handleSizeChange (newsize) {
      this.pageSize = newsize
      this.getAuditList()
    },
    handleCurrentChange (current) {
      this.pageIndex = current
      this.getAuditList()
    },
    handleAudit(row){
      console.log(row)
      this.dialogVisible=true
    },
    handleClose() {
        this.dialogVisible=false
      }
  }
}
</script>

<style lang='scss'>
.audit{
  width: 100%;
  .el-breadcrumb{
    line-height: 40px;
    height: 40px;
    border-bottom: 3px solid #4381E6;
    margin-bottom: 20px;
    font-size: 14px;
  }
  .el-row{
    .col1{
      span{
        display: inline-block;
        border:1px solid #4381E6;
        color: #4381E6;
        padding: 3px 8px;
        font-size: 14px;
      }
      span.active{
        color: #fff;
        background: #4381E6;
      }
    }
  }
}
</style>